package com.emailsystem.emailsystem.service.impl.server;

//import org.json.simple.JSONObject;
import com.alibaba.fastjson.JSONObject;

import java.io.ObjectInputStream;
import java.net.Socket;
import java.util.Map;

class Server_listen implements Runnable{
    private Socket socket;

    Server_listen(Socket socket){
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
            while (true) {
                JSONObject message=new JSONObject((Map) ois.readObject());
                System.out.println(message);
            }

        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try{
                socket.close();
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
